package com.wangjiacai.hqlQuery.role.repository;

import com.wangjiacai.hqlQuery.role.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-23 11:54:50
 */
public interface RoleRepository extends JpaRepository<Role,String> {

    Role findByName(String name);

    @Query("select name from Role where id in (?1)")
    List<String> findRoleNameByIdIn(List<String> ids);

    @Query("from Role where id in (select roleId from UserRole where userId = ?1)")
    List<Role> findByUserId(String userId);
}
